<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="/Public/Admin/css/style.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="/Public/Admin/js/jquery.js"></script>
    <script>
        $(function(){
            $('.add').live('click',function(){
              var str = "<li><label>商品图片[<a href='javascript:;' class='plus'>-</a>]</label><input name='goods_pic[]' type='file' /></li>";
              $(this).parent().parent().after(str);
            });
            $('.plus').live('click',function(){
              $(this).parent().parent().remove();
            });
            $('.del').live('click',function(){
              var _this = $(this);
              var id = $(this).attr('data');
              var data ={
                pic_id:id
              };
              $.post("<?php echo U('goods/picDel');?>",data,function(msg){
                //alert(msg);
                if(msg==1){
                  _this.parent().parent().remove();
                }else{
                  alert('删除失败');
                }
              });
            });
        });

    </script>
</head>

<body>
    <div class="place">
        <span>位置：</span>
        <ul class="placeul">
            <li><a href="#">首页</a></li>
            <li><a href="#">表单</a></li>
        </ul>
    </div>
    <div class="formbody">
        <div class="formtitle"><span>商品相册<font color="red"><?php echo ($goods_name); ?></font></span></div>

        <li style="border: 1px solid grey;margin-bottom: 20px;">
            <?php if(is_array($pic_info)): foreach($pic_info as $k=>$v): ?><span>
            <label>[<a href="javascript:;" data="<?php echo ($v["pic_id"]); ?>" class="del">-</a>]</label>
            <img src="<?php echo (substr($v["pic_mid"],1)); ?>" width="140">
            </span><?php endforeach; endif; ?>
        </li>

        <form action="<?php echo U('goodsphoto');?>" method="post" enctype="multipart/form-data">
            <ul class="forminfo">
                <li>
                    <label>商品图片[<a href="javascript:;" class="add">+</a>]</label>
                    <input name="goods_pic[]" type="file" />
                </li>

                <input type="hidden" name="goods_id" value="<?php echo ($goods_id); ?>">
                <li>
                    <label>&nbsp;</label>
                    <input name="" id="btnSubmit" type="submit" class="btn" value="确认保存" />
                </li>
            </ul>
        </form>
    </div>
</body>
<script type="text/javascript">
$(function(){
    $('#btnSubmit').on('click',function(){
        $('form').submit();
    });
</script>
</html>